package com.bdqn.config;

import com.bdqn.interceptor.Tokenlnterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Autowired
    Tokenlnterceptor tokenlnterceptor;
    /**
     * 添加token验证的拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //登录的控制器和openAPI
        String[] excludePatterns = new String[]{"/swagger-resources/**", "/webjars/**", "/v3/**", "/swagger-ui.html/**",
                "/api", "/api-docs", "/api-docs/**", "/doc.html/**","/user/checkLogin"};
        registry.addInterceptor(tokenlnterceptor).excludePathPatterns(excludePatterns);
    }
}
